<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>随附单信息</title>
    <jsp:include page="../../head.jsp"/>
</head>
<script type="text/javascript">
    var formSetting = {
        title: "随附单信息",
        module: 'query',
        numCount: '2',
        columns: [],
        buttons: {
            custom: [{
                id: "addbtn",
                value: "新增",
                click: function () {
                    location.href = ("manage?tid=${tid}&did=${did}");
                }
            }, {
                id: "updatebtn",
                value: "修改",
                click: function () {
                    var id = $("#dataGrid").jqGrid(
                            "getGridParam", "selrow");
                    if (id) {
                        var ret = $("#dataGrid").jqGrid(
                                'getRowData', id);
                        window.open("manage?id=" + ret.id);
                    } else {
                        jw.alert("请先点击选择需要查看修改的记录!");
                    }
                }
            }, {
                id: "delbtn",
                value: "删除",
                click: function () {
                    var id = $("#dataGrid").jqGrid(
                            "getGridParam", "selrow");
                    if (id) {
                        jw.confirm("确定要删除记录?", function () {
                            var ret = $("#dataGrid").jqGrid(
                                    'getRowData', id);
                            $.ajax({
                                       url: "del?id=" + ret.id,
                                       async: false,
                                       cache: false,
                                       success: function (data) {
                                           try {
                                               jw.alert(JSON.parse(data.msg).msg);
                                           } catch (e) {
                                           }
                                           setTimeout(function () {
                                               history.go(0);
                                           }, 1000);
                                       }
                                   });
                        }, function () {
                            return;
                        });
                    } else {
                        jw.alert("请先点击选择需要删除的记录!");
                    }
                }
            }]
        },
        grid: {
            id: "dataGrid",
            title: "查询结果",
            url: "findList?tid=${tid}&did=${did}",
            colModel: [{
                index: "id",
                name: "id",
                label: "id",
                hidden: true
            }, {
                index: "suifudan_co",
                name: "suifudan_co",
// 				label : "随附单代码",
                label: "随附单名称",
                hidden: true
            }, {
                index: "suifudan_co_cn",
                name: "suifudan_co_cn",
// 				label : "随附单代码"
                label: "随附单名称"
            }, {
                index: "suifudan_no",
                name: "suifudan_no",
                label: "随附单编号"
            }],
            sortorder: "desc",
//            jsonReader: {
//                root: "datas"
//            },
            loadComplete: function (data) {
                try {
                    if (data.content.length == 0) {
                        location.href = ("manage?tid=${tid}&did=${did}");
                    }
                } catch (e) {
                }
            }
        }
    };
    $(document).ready(function () {
        $("#dataTable").mrdForm(formSetting);
    });
</script>
<body>
<div id="dataTable"></div>
</body>
</html>
